// 基于template/src/widgets/{{appEntities}}/{{ctrls@GRID}}-grid/{{spinalCase ctrl.codeName}}-grid-model.ts.hbs生成
import { IGridModel, IParam, isEmpty, VerifyUtil } from '@/core';

function getModel(): IGridModel {
	return {
        cssName: "",        
		aggMode: 'NONE',
		caption: '',
		controlType: 'GRID',
		codeName: 'GridColumn',      
		columns: getGridColumns(),
		dataItems: getGridDataItems(),
		dataExport: getDataExport(),
		enableRowEdit: false,
		entityCodeName: 'IBIZBOOK',
		entityLogicName: '图书',
		createDefaultItems: getCreateDefaultItems(),
        updateDefaultItems: getUpdateDefaultItems(),
		name: 'grid',
		noSort: false,
		rules: {
            //	静态值规则
            staticRules: {
		    },
            //	编辑项值规则
            editRules: [
			]
    	},
		showHeader: true,
		sortDir: '',
		sortField: '',
		limit: 20,
		dataImport: {
			codeName: 'DataImport',
			ignoreError: false,
			importItems: [
				{
					name: 'author',
					caption: App.ts('DEF.LNAME.AUTHOR', '图书作者'),
				},
				{
					name: 'booknumber',
					caption: App.ts('DEF.LNAME.BOOKNUMBER', '图书数量'),
				},
				{
					name: 'borrowway',
					caption: App.ts('DEF.LNAME.BORROWWAY', '借阅方式'),
					codeListTag: 'Sample__CodeList25',
				},
				{
					name: 'ibizbookid',
					caption: App.ts('DEF.LNAME.IBIZBOOKID', '图书标识'),
				},
				{
					name: 'ibizbookname',
					caption: App.ts('DEF.LNAME.IBIZBOOKNAME', '图书名称'),
				},
				{
					name: 'press',
					caption: App.ts('DEF.LNAME.PRESS', '图书出版社'),
				},
				{
					name: 'price',
					caption: App.ts('DEF.LNAME.PRICE', '图书价格'),
				},
				{
					name: 'sailstate',
					caption: App.ts('DEF.LNAME.SAILSTATE', '图书销售状态'),
					codeListTag: 'Sample__BookSailState',
				},
				{
					name: 'subtext',
					caption: App.ts('DEF.LNAME.SUBTEXT', '图书描述'),
				},
				{
					name: 'tag',
					caption: App.ts('DEF.LNAME.TAG', '标签'),
				},
				{
					name: 'type',
					caption: App.ts('DEF.LNAME.TYPE', '图书类型'),
					codeListTag: 'Sample__BookType',
				}
			]
		},
		paging: {
			defaultPageSize: 20,
		},
		ctrlMsgModel:[
    ],
		uiEngineModel: [
            {
                name: 'engine_grid',
                triggerType: 'CTRLEVENT',
                logicType: 'APPVIEWENGINE',
                eventNames: 'ROWDBLCLICK;SELECTIONCHANGE;REMOVE;LOAD;BEFORELOAD',
                scriptCode: ``,
                entityCodeName: '',
                logicName:``
            }
    ]
    }
}
//  获取所有表格列模型
function getGridColumns():IParam[] {
  return [
		{
			align: 'left',
			codeName: 'ibizbookname',
			caption: '图书名称',
			captionLanResTag: 'DEF.LNAME.IBIZBOOKNAME',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
		    pluginCode: 'dynamicGridColumn',
			dataItemName: 'ibizbookname',
			dataIndex: 'ibizbookname',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '图书名称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'ibizbookname',
		    width: 100,
		    minWidth: 100,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'borrowstatus',
			caption: '图书借阅状态',
			captionLanResTag: 'DEF.LNAME.BORROWSTATUS',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
			dataItemName: 'borrowstatus',
			dataIndex: 'borrowstatus',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '图书借阅状态',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'borrowstatus',
		    width: 100,
		    minWidth: 100,
		    resizable: true,
			stdDataType: 9,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'booknumber',
			caption: '图书数量',
			captionLanResTag: 'DEF.LNAME.BOOKNUMBER',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
			dataItemName: 'booknumber',
			dataIndex: 'booknumber',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '图书数量',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'booknumber',
		    width: 100,
		    minWidth: 100,
		    resizable: true,
			stdDataType: 9,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'author',
			caption: '图书作者',
			captionLanResTag: 'DEF.LNAME.AUTHOR',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
		    pluginCode: 'dynamicGridColumn',
			dataItemName: 'author',
			dataIndex: 'author',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '图书作者',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'author',
		    width: 100,
		    minWidth: 100,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'type',
			caption: '图书类型',
			captionLanResTag: 'DEF.LNAME.TYPE',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
		    valueType: "SIMPLE",
		    codeListTag: 'Sample__BookType',
			dataItemName: 'type',
			dataIndex: 'type',
		    sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
		    filterName: '',
		    filterCodeListTag: '',
		    filterCodeListType: '',
			enableSort: true,
			excelCaption: '图书类型',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'type',
		    width: 100,
		    minWidth: 100,
		    resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
  ];
}

//  获取所有表格数据项
function getGridDataItems() {
  return [
    {
			name: 'ibizbookname',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizbookname',
			fieldName: 'ibizbookname',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'borrowstatus',
			codeName: '',
            customCode: false,
			fieldCodeName: 'borrowstatus',
			fieldName: 'borrowstatus',
			valueFormat: '',
			dataType: '9'
    },
    {
			name: 'booknumber',
			codeName: '',
            customCode: false,
			fieldCodeName: 'booknumber',
			fieldName: 'booknumber',
			valueFormat: '',
			dataType: '9'
    },
    {
			name: 'author',
			codeName: '',
            customCode: false,
			fieldCodeName: 'author',
			fieldName: 'author',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'type',
			codeName: '',
            customCode: false,
			fieldCodeName: 'type',
			fieldName: 'type',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'ibizbookid',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizbookid',
			fieldName: 'ibizbookid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfkey',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizbookid',
			fieldName: 'ibizbookid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfdataaccaction',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizbookid',
			fieldName: 'ibizbookid',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfmajortext',
			codeName: '',
            customCode: false,
			fieldCodeName: 'ibizbookname',
			fieldName: 'ibizbookname',
			valueFormat: '',
			dataType: '25'
    },
    {
			name: 'srfmstag',
			codeName: '',
            customCode: false,
    },
  ];
}

function getDataExport() {
	return {
        default: true,
		codeName: 'default',
		enableFront: true,
		fileName: '图书',
		exportItems: [
			{
				name: 'ibizbookname',
				label: '图书名称',
  				labelLanResTag: 'DEF.LNAME.IBIZBOOKNAME',
				dataType: 25,
				show: true
			},
			{
				name: 'borrowstatus',
				label: '图书借阅状态',
  				labelLanResTag: 'DEF.LNAME.BORROWSTATUS',
				dataType: 9,
				show: true
			},
			{
				name: 'booknumber',
				label: '图书数量',
  				labelLanResTag: 'DEF.LNAME.BOOKNUMBER',
				dataType: 9,
				show: true
			},
			{
				name: 'author',
				label: '图书作者',
  				labelLanResTag: 'DEF.LNAME.AUTHOR',
				dataType: 25,
				show: true
			},
			{
				name: 'type',
				label: '图书类型',
  				labelLanResTag: 'DEF.LNAME.TYPE',
				dataType: 25,
				codeListTag: 'Sample__BookType',
				show: true
			}
		]
	}
}

function getCreateDefaultItems() {
	return [
	]
}

function getUpdateDefaultItems() {
	return [
	];
}

export const model = getModel();